var locationMap;

function initMap() {
	var customparams = {
		center : new google.maps.LatLng(36, -232),
		zoom : 7,
		mapTypeId : google.maps.MapTypeId.ROADMAP
	};
	locationMap = right_location_layout.attachMap(customparams);
}

function createMarker(id) {
	var markerRequest = $.ajax({
		url : '/bwf/device/' + id,
		type : 'GET',
		dataType : 'json'
	});
	markerRequest.done(function(info) {
		marker = new google.maps.Marker({
			map : locationMap,
			position : new google.maps.LatLng(parseInt(info['latitude']),
					parseInt(info['longitude'])),
			draggable : true, // Bounce
			animation : google.maps.Animation.DROP
		// Bounce 
		});
		var infowindow = new google.maps.InfoWindow({
			content : info['name']
		});

		google.maps.event.addListener(marker, 'click', function() {
			infowindow.close(locationMap, marker);
		});
		infowindow.open(locationMap, marker);
	});
	markerRequest.fail(function(jqXHR, textStatus) {
		alert('Request failed!');
	});
}
